package zuoye;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;

public class Doudizhu {
	public static void main(String[] args) {
		ArrayList<String> poker=new ArrayList<String>();
		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		poker.add("大王");
		poker.add("小王");
		ArrayList<Integer> list=new ArrayList<>();
		for(String number:numbers){
			for(String color:colors){
				poker.add(color+number);
			}
		}
		System.out.println(poker);
		HashMap<Integer, String> map=new HashMap<>();
		for(int i=0;i<poker.size();i++){
			map.put(i, poker.get(i));
			list.add(i);
		}
		Collections.shuffle(list);
		System.out.println(list);
		
		Player p1=new Player();p1.setName("老王");
		Player p2=new Player();p2.setName("老李");
		Player p3=new Player();p3.setName("老六");
		ArrayList<String> dipai=new ArrayList<String>();
		ArrayList<Integer> list1=new ArrayList<>();
		ArrayList<Integer> list2=new ArrayList<>();
		ArrayList<Integer> list3=new ArrayList<>();
		for(int i=0;i<list.size();i++){
			int n=list.get(i);
			if(i>=51){
				dipai.add(map.get(n));
			}else if(i%3==0){
				list1.add(n);
			}else if(i%3==1){
				list2.add(n);
			}else if(i%3==2){
				list3.add(n);
			}
		}
		Collections.sort(list1, new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
		});
		Collections.sort(list2, new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
		});
		Collections.sort(list3, new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				return o2-o1;
			}
		});
		for(int i=0;i<list1.size();i++){
			p1.getPoker().add(map.get(list1.get(i)));
		}
		for(int i=0;i<list2.size();i++){
			p2.getPoker().add(map.get(list2.get(i)));
		}
		for(int i=0;i<list3.size();i++){
			p3.getPoker().add(map.get(list3.get(i)));
		}
		System.out.println(p1.getName()+"的牌:"+p1.getPoker());
		System.out.println(p2.getName()+"的牌:"+p2.getPoker());
		System.out.println(p3.getName()+"的牌:"+p3.getPoker());
		System.out.println("底牌:"+dipai);
	}    
}
